package research.proxy;

import java.lang.reflect.Proxy;

public class Test {

	private AnInterface anInterface;
	
	@SuppressWarnings("unchecked")
	public Test(Class clazz) {
		Class[] interfaces = {clazz};
		this.anInterface = (AnInterface) Proxy.newProxyInstance(this.getClass().getClassLoader(), interfaces, new ProxyClass());
	}
	
	public AnInterface getAnInterface() {
		return this.anInterface;
	}
	
	public static void main(String[] args) {
		AnInterface it1 = (new Test(AnInterface.class)).getAnInterface();
		System.out.println("1. " + it1.hello());
		System.out.println("2. " + it1.notHello());
	}
}
